#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // 设置表格的列数 字段
    ui->tableWidget->setColumnCount(3);
    ui->tableWidget->setHorizontalHeaderLabels(QStringList()<<"姓名"<<"班级"<<"考试成绩");

    // 设置表格行数
    ui->tableWidget->setRowCount(10);

    ui->tableWidget->setItem(0,0,new QTableWidgetItem("温11"));
    ui->tableWidget->setItem(0,1,new QTableWidgetItem("GZ25合班6"));
    ui->tableWidget->setItem(0,2,new QTableWidgetItem("100"));

    ui->tableWidget->setItem(1,0,new QTableWidgetItem("温22"));
    ui->tableWidget->setItem(1,1,new QTableWidgetItem("GZ25合班6"));
    ui->tableWidget->setItem(1,2,new QTableWidgetItem("86"));

}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_tableWidget_cellDoubleClicked(int row, int column)
{
//    ui->tableWidget->clear();
    ui->tableWidget->takeItem(row,column);
}

void MainWindow::on_tableWidget_itemDoubleClicked(QTableWidgetItem *item)
{
    qDebug() << item->text();
}

void MainWindow::on_Search_pbtn_clicked()
{
    QString text = ui->searchlineEdit->text();
    auto qlistTableWidgetItem =  ui->tableWidget->findItems(text,Qt::MatchStartsWith);
    qDebug() << qlistTableWidgetItem.at(0)->row() << " " << qlistTableWidgetItem.at(0)->column();
}
